/*
 * Copyright 2003-2005 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

#ifndef TYPEINPUTSTREAM
#define TYPEINPUTSTREAM

#ifdef __cplusplus
extern "C" {
#endif


typedef int (*argot_read)( type_input_stream * in, void * data, char * buffer, int size );

/* data structure for input stream.
 * 
 * 
 */
struct type_input_stream
{
	void * data;  /* private data for functions */
	int error; /* error reporting */
	struct type_map * map; /* type map */
	argot_read read_buffer; /* function to read buffer */
	type_stack stack; /* element stack */
};
 

/* Create a input structure */
void type_input_init( type_input_stream * in, type_map * map, argot_read ar, void * data );

/* Destroy a input structure */
void type_input_destroy( type_input_stream * tis );

/* Set an error on the stream */
void type_input_set_error( type_input_stream * tis, int rc );

/* Get/Check error on stream. Returns NULL if no error */
int type_input_get_error( type_input_stream * tis );

#define type_input_stack( tis ) &((tis)->stack)

/* Read a buffer from the stream */
#define type_input_read_buffer( tis, buffer, size ) ((tis)->read_buffer( (tis), (tis)->data, (buffer), (size) ))

/* Get the type map for the stream */
#define type_input_type_map( tis ) ((tis)->map)

void type_input_set_type_map( type_input_stream * tis, type_map * map );

/* Read an object using the system id from the stream */
int type_input_read_object( type_input_stream * tis,int systemId );

/* Read an object using the object name */
int type_input_read_named_object( type_input_stream * tis, type_name * name );

#define type_input_set_type( tis, element ) ((tis)->stack.top->type = (element))

#ifdef __cplusplus
}
#endif

#endif
